using System.Collections.Generic;
using System.Linq;
using System.Web.UI;
using Ext.Net;


namespace Ext.Net.UIS
{
    public class FieldSetEditor : TermEditor
    {
        public static FieldSetEditor Default = new FieldSetEditor();
        public static FieldSetEditor Default2 = new FieldSetEditor { Collapsible = true, };


        public bool Collapsible { get; set; }

        public override IEnumerable<AbstractComponent> NewControls(TermNode node, UisCreateControlArgs e)
        {
            var row = new FieldSet
            {
                TermNode = node,
                ViewState = e.BaseViewState,
                Collapsible = Collapsible,
            };

            e.BaseViewState = null;
            var newItems = node.NewItemControls(e).ToList();
            row.Items.AddRange(newItems);

            return new[] { row };
        }

    }
}